#include "opencv2/imgcodecs.hpp"
#include "opencv2/opencv.hpp"
int main(){
    // 创建深灰色背景图像
    cv::Mat mat(320,240,CV_8UC3,cv::Scalar(32,32,32));
    // 在图像上绘制文本
    cv::putText(mat,"Student Number: ******",cv::Point(60,60),cv::FONT_HERSHEY_SIMPLEX,0.3,cv::Scalar(255,255,255),1,8,false);
    // 设置 PNG 压缩参数
    std::vector<int> compression_params;
    compression_params.push_back(cv::IMWRITE_PNG_COMPRESSION);
    compression_params.push_back(9);
    // 保存图像
    bool result =false;
    try{
        result = imwrite("id.png",mat,compression_params);
        if(result){
            std::cout<<"Succeed!"<<std::endl;
        }
        else{
            std::cout<<"Faile!"<<std::endl;
        }
    }
    catch(const cv::Exception& ex){
        fprintf(stderr,"Exception convertign image to PNG format: %s\n",ex.what());
    }
    cv::imshow("Task 1_4",mat);
    cv::waitKey(0);
    return 0;
}